/**
 * Copyright (C), 2015-2020, bogewang
 * FileName: HelloConsumerService
 * Author:   foren236598164@aliyun.com
 * Date:     2020/5/12 9:10
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.bogewang.consumer;

import com.bogewang.api.HelloService;
import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 〈一句话功能简述〉
 * 〈〉
 *
 * @author foren236598164@aliyun.com
 * @create 2020/5/12
 * @since 1.0.0
 */
@RestController
@RequestMapping("/consumerhello")
public class HelloConsumerService implements HelloService {

    @Autowired
    RestTemplate restTemplate = RestTemplateBuilder.create();

    @Override
    @GetMapping("/sayhello")
    public String sayHello(String name) {
        String providerName = "provider";
        String rtnValue = restTemplate.getForObject("cse://" + providerName + "/providerhello/sayhello?name=" + name, String.class);
        return rtnValue;
    }
}
